<div id="trendsPage">
    <div class="post">
        <h2 class="title">Clients</h2>
        <div class="entry">
            <input type="button" value="Add new" onclick="show('#new_trend')"/>
            <?php
         //   if ($this->session->userdata("admin")) {
            ?>
                <input type="button" value="Search" onclick="show('#searchTrends')"/>
                <input type="button" value="Clear Search" onclick="clearSearch()"/>
            <?php
         //   }
            ?>
            <div id="trends_result" class="info">
                <?= $message ?>
            </div>
            <script type="text/javascript">
                function searchTrends(){
                    field=document.getElementById("searchTrendsForm").field.value;
                    search=document.getElementById("searchTrendsForm").search.value;
                    $("#trendsPage").load("<?= base_url(); ?>index.php?/admin_mis/trends/"+field+"/"+search);
                }
                function clearSearch(){
                    $("#trendsPage").load("<?= base_url(); ?>index.php?/admin_mis/trends/");
                }
            </script>

            <script type="text/javascript">
                $(function() {
                    $( "#trend_datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });
                });
                $(function() {
                    $( "#trend_datepicker1" ).datepicker({ dateFormat: 'yy-mm-dd' });
                });
                $(function() {
                    $( "#trend_datepicker2" ).datepicker({ dateFormat: 'yy-mm-dd' });
                });
            </script>
            <!--a href="" id="hide3" >Hide</a> <a href="" id="show3" >Show</a-->
            <div id="new_trend" style="display: none;margin-bottom: 10px;">
                <?php $data['id'] = "trend_form" ?>
                <?= form_open_multipart('mis/saveTrend', $data); ?>
                <table>
                    <tr class="lighter"><td class="half">SBU(Strategic Business Unit)</td><td>
                            <select name="SBU">
                                <?php foreach ($sbus as $type): ?>
                                    <option value="<?= $type->tid; ?>"><?= $type->name; ?></option>
                                <?php endforeach; ?>
                                </select>
                            </td> </tr>
                        <tr class="darker"><td class="half">Client</td><td>
                                <select name="client_name">
                                <?php foreach ($clients as $type): ?>
                                        <option value="<?= $type->tid; ?>"><?= $type->name; ?></option>
                                <?php endforeach; ?>
                                    </select>
                            <tr class="lighter"><td class="half">Type of Service</td><td>
                                    <select name="service_type">
                                <?php foreach ($serv_types as $type): ?>
                                            <option value="<?= $type->tid; ?>"><?= $type->name; ?></option>
                                <?php endforeach; ?>
                                        </select>
                                <tr class="darker"><td class="half">Date pre-qualified</td><td><input type="text" class="wide" name="date_prequalified" value="<?php echo set_value('date_prequalified'); ?>" id="trend_datepicker2" /></td> </tr>
                                <tr class="lighter"><td class="half">Engagement From</td><td><input type="text" class="wide" name="engagement_from" value="<?php echo set_value('engagement_from'); ?>" id="trend_datepicker" /></td> </tr>
                                <tr class="darker"><td class="half">Engagement To</td><td><input type="text" class="wide" name="engagement_to" value="<?php echo set_value('engagement_to'); ?>" id="trend_datepicker1" /></td> </tr>

                                <tr><td colspan="2" style="text-align: right">
                                        <input type="submit" value="Submit" />
                                        <input type="button" value="Cancel" onclick="hide('#new_trend')"/>
                                    </td></tr>
                            </table>
                            </form>
                        </div>


                        <div id="searchTrends" style="display: none;margin-bottom: 10px;">
                            <form id="searchTrendsForm">
                                <table>
                                    <tr class="darker"><td class="half">Select search criteria</td>
                                        <td><select name="field">
                                                <option selected="selected" value='added_by'> Added by</option>
                                                <option value='client_name' >Client name</option>
                                                <option value='purpose' >Purpose</option>
                                            </select></td>
                                        <td><input type="text" name="search" class="wide"  value="<?php echo set_value('added_by'); ?>" /></td>
                                    </tr>

                                    <tr><td colspan="3" style="text-align: right">
                                            <input type="button" value="Submit" onclick="searchTrends()" />
                                            <input type="button" value="Cancel" onclick="hide('#searchTrends')"/>
                                        </td></tr>

                                </table>
                            </form>
                        </div>
                        <div id="all_trends">
                <?= $tablet ?>
                <?= $pagina ?>
            </div>

        </div>
    </div>